﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ServiceApplication.Service;
using ServiceApplication.Service.Basic;
using CommonLibrary.DataModel.Basic;

namespace AspWebTest
{
    public partial class FormList : System.Web.UI.Page
    {
        FormService formService = new FormService();
        BasicService basicService = new BasicService();
        protected void Page_Load(object sender, EventArgs e)
        {
            UserEntity userEntity = basicService.QueryUserByLoginid(Session["loginid"].ToString());
            Gridview1.DataSource = formService.QueryFormDataTable(userEntity.id);
            Gridview1.DataBind();

            //增加一行
            //int columnCount = dt.Columns.Count;
            //GridViewEmptyDataTest.Rows[0].Cells.Clear();
            //GridViewEmptyDataTest.Rows[0].Cells.Add(new TableCell());
            //GridViewEmptyDataTest.Rows[0].Cells[0].ColumnSpan = columnCount;
            //GridViewEmptyDataTest.Rows[0].Cells[0].Text = "没有记录";
            //GridViewEmptyDataTest.Rows[0].Cells[0].Style.Add("text-align", "center");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("FormSetting.aspx");
        }

        protected void Gridview1_PreRender(object sender, EventArgs e)
        {
            for (int i = 0; i < Gridview1.Rows.Count; i++)
            {
                if (Gridview1.Rows[i].RowType == DataControlRowType.DataRow)
                {
                    string s=Gridview1.Rows[i].Cells[1].Text;
                    string ss = Gridview1.Rows[i].Cells[2].Text;
                    Gridview1.Rows[i].Attributes.Add("onclick", "window.open('FormShow.aspx?formid=" + this.Gridview1.DataKeys[i].Values[0].ToString() + "')");

                    //增加鼠标移动时的颜色改变
                    Gridview1.Rows[i].Attributes["style"] = "Cursor:hand;";
                    Gridview1.Rows[i].Attributes.Add("onmouseover", "this.style.backgroundColor='#439be6'");
                    Gridview1.Rows[i].Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");


                }
            }
        }
    }
}

